package com.yourbatis.syntax;

import com.yourbatis.interpreter.Environment;

public class PrefixIncrement implements Expression {
    private final String variableName;

    public PrefixIncrement(String variableName) {
        this.variableName = variableName;
    }

    @Override
    public Object eval() {
        // 先自增再返回值
        int newValue = (Integer) Environment.get(variableName) + 1;
        Environment.assign(variableName, newValue);
        return newValue;
    }
}
